package com.it;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.junit.Test;

public class test001 {

    @Test
    public void test001() {
        //创建procerssEngliConfigurationd对象,第二个参数是propeca的id
        ProcessEngineConfiguration configuration =
                ProcessEngineConfiguration
                        .createProcessEngineConfigurationFromResource("activiti.cfg.xml","processEngineConfiguration");
        ProcessEngine processEngine =
                configuration.buildProcessEngine();
        System.out.println(processEngine);

    }


    @Test
    public void test002() {
        //ProcessEngineConfiguration
        ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
       //创建ProcesEnglish的位置
        ProcessEngine processEngine = configuration.buildProcessEngine();


        //processEngine.
        RepositoryService repositoryService = processEngine
                .getRepositoryService();
        Deployment deployment = repositoryService.createDeployment()
                .addClasspathResource("diagram/holiday.bpmn")
                .addClasspathResource("diagram/holiday.png")
                .name("请假申请流程")
                .deploy();
        System.out.println("流程部署id"+deployment.getId());
        System.out.println("流程部署名称"+deployment.getName());

    }


    @Test
    public  void  test03(){
        //条件 01：activite的配置文件：名称activite.cfg.xml,beanid必须是:processEngineConfiguration
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        System.out.println("processEngine = " + processEngine);
        RepositoryService repositoryService = processEngine.getRepositoryService();
        System.out.println("repositoryService = " + repositoryService);
        String name = processEngine.getName();
        System.out.println("name = " + name);

    }
}
